import fg from 'fast-glob';
import fs from 'fs';
import path from 'path';

const ws = 'D:/works/dpxyx/trunk/project/Assets';
const metas = fg.sync('**/*.png.meta', { cwd: ws });

for (const meta of metas) {
    const p = path.join(ws, meta);
    const content = fs.readFileSync(p, 'utf-8');
    const lines = content.split(/\r?\n/);
    for (const line of lines) {
        const mch = line.match(/border: \{x: (.+), y: (.+), z: (.+), w: (.+)\}/);
        if (mch) {
            const x = Number(mch[1]), y = Number(mch[2]), z = Number(mch[3]), w = Number(mch[4]);
            if (x != 0 || y != 0 || z != 0 || w != 0) {
                console.error(`${p}: ${line} (Error)`);
            } else {
                console.log(`${p}: ${line} (OK)`);
            }
        }
    }
}
